/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.c0910g.DAO;

import com.myapp.c0910g.entity.UserRadioCab;
import com.myapp.c0910g.entity.UserRadioCabFacade;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author BachLe
 */
public class UserRadioCabDAO {
    UserRadioCabFacade userRadioCabFacade = lookupUserRadioCabFacadeBean();

    private UserRadioCabFacade lookupUserRadioCabFacadeBean() {
        try {
            Context c = new InitialContext();
            return (UserRadioCabFacade) c.lookup("java:global/RadioCabsProject/RadioCabsProject-ejb/UserRadioCabFacade!com.myapp.c0910g.entity.UserRadioCabFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public UserRadioCab loginAction(String role, String name, String pass){
        return userRadioCabFacade.loginForAll(role, name, pass);
    }

    public UserRadioCab loginActionForAdvertise(String role, String name){
        return userRadioCabFacade.login(role, name);
    }

    public List<UserRadioCab> getAllUserExceptAdmin(){
        return userRadioCabFacade.getAllUserRadioCabs();
    }

    public UserRadioCab getUserByID(String userID){
        return userRadioCabFacade.getUserRadioCabByID(userID);
    }

    public void addNewUser(UserRadioCab user){
        userRadioCabFacade.create(user);
    }

    public void editUser(UserRadioCab user){
        userRadioCabFacade.edit(user);
    }

    public void deleteUser(UserRadioCab user){
        userRadioCabFacade.remove(user);
    }

    public UserRadioCab findUserById(int userId){
        return userRadioCabFacade.find(userId);
    }

    public List<UserRadioCab> findListByCity(String city){
        return userRadioCabFacade.getListingByCity(city);
    }

    public List<UserRadioCab> findDriverByCity(String city){
        return userRadioCabFacade.getDriverByCity(city);
    }

    public List<UserRadioCab> findAdvertiseByCity(String city){
        return userRadioCabFacade.getAdvertiseByCity(city);
    }

    public List<UserRadioCab> findAllListing(){
        return userRadioCabFacade.getListing();
    }

    public List<UserRadioCab> findAllDriver(){
        return userRadioCabFacade.getDriver();
    }

    public List<UserRadioCab> findAllAdvertise(){
        return userRadioCabFacade.getAdvertise();
    }

    public int updateUserNotPayStatus(Integer userid){
        return userRadioCabFacade.updateStatusUser(userid);
    }

    public int updateUserPayStatus(Integer userid){
        return userRadioCabFacade.updateStatusPayUser(userid);
    }
}
